import 'package:flutter/material.dart';
import 'package:flutter_api/widgets/title_text_container.dart';

class IntrinsicHeightPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(12.0),
      child: ListView(
        children: [
          TitleTextContainer('延伸组件(IntrinsicHeight)',
              child: IntrinsicHeightWidget()),
        ],
      ),
    );
  }
}

// Row中三个元素，其中第一个元素高度不固定，要求剩余两个元素要跟随第一个元素伸缩
// IntrinsicHeight 表示固定高度
class IntrinsicHeightWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: IntrinsicHeight(
        child: Row(
          children: [
            Container(width: 30, height: 50, color: Colors.redAccent),
            Container(width: 40, color: Colors.green),
            Container(width: 20, color: Colors.yellow),
          ],
        ),
      ),
    );
  }
}
